﻿using System;
using System.IO;

namespace OfficeConvert.Core
{
    public static class OfficeConvertFactory
    {
        public static IOfficeConvert GetConvert(string sourceFullName)
        {
            var extensionName = Path.GetExtension(sourceFullName);

            switch (extensionName.ToUpper())
            {
                case ".XLS":
                case ".XLSX":
                    return new ExcelConvert();
                case ".DOC":
                case ".DOCX":
                    return new WordConvert();
                case ".PPT":
                case ".PPTX":
                    return new PowerPointConvert();
                default:
                    throw new Exception($"不支持的文件类型：{extensionName}");
            }
        }
    }
}
